/*
Supersized - Fullscreen Slideshow jQuery Plugin
By Sam Dunn (www.buildinternet.com // www.onemightyroar.com)
Version: supersized.2.0.js // Relase Date: 5/7/09
Website: www.buildinternet.com
Thanks to Aen for preloading, fade effect, & vertical centering
*/

(function($){	

    $.fn.supersized = function () {
        $.inAnimation = false;
        $.paused = false;
        var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);

        $(window).bind("load", function () {
            $('#loading').hide();
            $('#supersize').fadeIn('fast');
            $('#content').show();
            if ($('#slideshow .activeslide').length == 0) $('#supersize a:first').addClass('activeslide');
            if (options.slide_captions == 1) $('#slidecaption').html($('#supersize .activeslide').find('img').attr('title'));
            if (options.navigation == 0) $('#navigation').hide();
            //Slideshow
            if (options.slideshow == 1) {
                if (options.slide_counter == 1) { //Initiate slide counter if active
                    $('#slidecounter .slidenumber').html(1);
                    $('#slidecounter .totalslides').html($("#supersize > *").size());
                }
                slideshow_interval = setInterval("nextslide()", options.slide_interval);
                
            }
        });

        $(document).ready(function () {
            $('#supersize').resizenow();
        });

        $(window).bind("resize", function () {
            $('#supersize').resizenow();
        });

        $('#supersize').hide();
        $('#content').hide();
    };

    $.fn.supersized1 = function () {
        $.inAnimation1 = false;
        $.paused = false;
        var options = $.extend($.fn.supersized1.defaults, $.fn.supersized1.options);

        $(window).bind("load", function () {
            $('#loading1').hide();
            $('#supersize1').fadeIn('fast');
            $('#content1').show();
            if ($('#slideshow1 .activeslide').length == 0) $('#supersize1 a:first').addClass('activeslide');
            if (options.slide_captions == 1) $('#slidecaption1').html($('#supersize1 .activeslide').find('img').attr('title'));
            if (options.navigation == 0) $('#navigation1').hide();
            //Slideshow
            if (options.slideshow == 1) {
                if (options.slide_counter == 1) { //Initiate slide counter if active
                    $('#slidecounter1 .slidenumber').html(1);
                    $('#slidecounter1 .totalslides').html($("#supersize1 > *").size());
                }
                slideshow_interval1 = setInterval("nextslide1()", options.slide_interval);                
            }
        });

        $(document).ready(function () {
            $('#supersize1').resizenow1();
        });        

        $(window).bind("resize", function () {
            $('#supersize1').resizenow1();
        });

        $('#supersize1').hide();
        $('#content1').hide();
    };

    $.fn.supersized2 = function () {
        $.inAnimation2 = false;
        $.paused = false;
        var options = $.extend($.fn.supersized2.defaults, $.fn.supersized2.options);

        $(window).bind("load", function () {
            $('#loading12').hide();
            $('#supersize2').fadeIn('fast');
            $('#content2').show();
            if ($('#slideshow2 .activeslide').length == 0) $('#supersize2 a:first').addClass('activeslide');
            if (options.slide_captions == 1) $('#slidecaption2').html($('#supersize2 .activeslide').find('img').attr('title'));
            if (options.navigation == 0) $('#navigation2').hide();
            //Slideshow
            if (options.slideshow == 1) {
                if (options.slide_counter == 1) { //Initiate slide counter if active
                    $('#slidecounter2 .slidenumber').html(1);
                    $('#slidecounter2 .totalslides').html($("#supersize2 > *").size());
                }
                slideshow_interval1 = setInterval("nextslide2()", options.slide_interval);
            }
        });

        $(document).ready(function () {
            $('#supersize2').resizenow2();
        });

        $(window).bind("resize", function () {
            $('#supersize2').resizenow2();
        });

        $('#supersize2').hide();
        $('#content2').hide();
    };

    $.fn.supersized3 = function () {
        $.inAnimation3 = false;
        $.paused = false;
        var options = $.extend($.fn.supersized3.defaults, $.fn.supersized3.options);

        $(window).bind("load", function () {
            $('#loading3').hide();
            $('#supersize3').fadeIn('fast');
            $('#content3').show();
            if ($('#slideshow3 .activeslide').length == 0) $('#supersize3 a:first').addClass('activeslide');
            if (options.slide_captions == 1) $('#slidecaption3').html($('#supersize3 .activeslide').find('img').attr('title'));
            if (options.navigation == 0) $('#navigation3').hide();
            //Slideshow
            if (options.slideshow == 1) {
                if (options.slide_counter == 1) { //Initiate slide counter if active
                    $('#slidecounter3 .slidenumber').html(1);
                    $('#slidecounter3 .totalslides').html($("#supersize3 > *").size());
                }
                slideshow_interval3 = setInterval("nextslide3()", options.slide_interval);
            }
        });

        $(document).ready(function () {
            $('#supersize3').resizenow3();
        });

        $(window).bind("resize", function () {
            $('#supersize3').resizenow3();
        });

        $('#supersize3').hide();
        $('#content3').hide();
    };
	
	//Adjust image size
	$.fn.resizenow = function() {
		
	};
    //Adjust image size
	$.fn.resizenow1 = function () {

	};
    //Adjust image size
	$.fn.resizenow2 = function () {

	};
    //Adjust image size
	$.fn.resizenow3 = function () {

	};
	
	$.fn.supersized.defaults = { 
			startwidth: 4,  
			startheight: 3,
			vertical_center: 1,
			slideshow: 1,
			navigation:1,
			transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
			pause_hover: 0,
			slide_counter: 1,
			slide_captions: 1,
			slide_interval: 5000
	};
	$.fn.supersized1.defaults = {
	    startwidth: 4,
	    startheight: 3,
	    vertical_center: 1,
	    slideshow: 1,
	    navigation: 1,
	    transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
	    pause_hover: 0,
	    slide_counter: 1,
	    slide_captions: 1,
	    slide_interval: 5000
	};
	$.fn.supersized2.defaults = {
	    startwidth: 4,
	    startheight: 3,
	    vertical_center: 1,
	    slideshow: 1,
	    navigation: 1,
	    transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
	    pause_hover: 0,
	    slide_counter: 1,
	    slide_captions: 1,
	    slide_interval: 5000
	};
	$.fn.supersized3.defaults = {
	    startwidth: 4,
	    startheight: 3,
	    vertical_center: 1,
	    slideshow: 1,
	    navigation: 1,
	    transition: 1, //0-None, 1-Fade, 2-slide top, 3-slide right, 4-slide bottom, 5-slide left
	    pause_hover: 0,
	    slide_counter: 1,
	    slide_captions: 1,
	    slide_interval: 5000
	};
})(jQuery);

	//Slideshow Next Slide
	function nextslide() {
		if($.inAnimation) return false;
		else $.inAnimation = true;
	    var options = $.extend($.fn.supersized.defaults, $.fn.supersized.options);
	    var currentslide = $('#supersize .activeslide');	    
	    currentslide.removeClass('activeslide');	    
		
	    if (currentslide.length == 0) currentslide = $('#supersize a:last');	    
			
	    var nextslide =  currentslide.next().length ? currentslide.next() : $('#supersize a:first');
	    var prevslide = nextslide.prev().length ? nextslide.prev() : $('#supersize a:last');
		
		
		//Display slide counter
		if (options.slide_counter == 1){
		    var slidecount = $('#slidecounter .slidenumber').html();
		    currentslide.next().length ? slidecount++ : slidecount = 1;
		    $('#slidecounter .slidenumber').html(slidecount);
		}
		
		$('.prevslide').removeClass('prevslide');
		prevslide.addClass('prevslide');
		
		//Captions require img in <a>
		if (options.slide_captions == 1) $('#slidecaption').html($(nextslide).find('img').attr('title'));
		
		nextslide.hide().addClass('activeslide')
	    	if (options.transition == 0){
	    	    nextslide.show(); $.inAnimation = false;
	    	}
	    	if (options.transition == 1){
	    	    nextslide.fadeIn(750, function () { $.inAnimation = false; });
	    	}
	    	if (options.transition == 2){
	    	    nextslide.show("slide", { direction: "up" }, 'slow', function () { $.inAnimation = false; });
	    	}
	    	if (options.transition == 3){
	    	    nextslide.show("slide", { direction: "right" }, 'slow', function () { $.inAnimation = false; });
	    	}
	    	if (options.transition == 4){
	    	    nextslide.show("slide", { direction: "down" }, 'slow', function () { $.inAnimation = false; });
	    	}
	    	if (options.transition == 5){
	    	    nextslide.show("slide", { direction: "left" }, 'slow', function () { $.inAnimation = false; });
	    	}
	    	
	    $('#supersize').resizenow();
	}

	function nextslide1() {
	    if ($.inAnimation1) return false;
	    else $.inAnimation1 = true;
	    var options = $.extend($.fn.supersized1.defaults, $.fn.supersized1.options);
	    var currentslide1 = $('#supersize1 .activeslide');
	    currentslide1.removeClass('activeslide');

	    if (currentslide1.length == 0) currentslide1 = $('#supersize1 a:last');

	    var nextslide1 = currentslide1.next().length ? currentslide1.next() : $('#supersize1 a:first');
	    var prevslide1 = nextslide1.prev().length ? nextslide1.prev() : $('#supersize1 a:last');


	    //Display slide counter
	    if (options.slide_counter == 1) {
	        var slidecount1 = $('#slidecounter1 .slidenumber').html();
	        currentslide1.next().length ? slidecount1++ : slidecount1 = 1;
	        $('#slidecounter1 .slidenumber').html(slidecount1);
	    }

	    $('.prevslide1').removeClass('prevslide');
	    prevslide1.addClass('prevslide');

	    //Captions require img in <a>
	    if (options.slide_captions == 1) $('#slidecaption1').html($(nextslide1).find('img').attr('title'));

	    nextslide1.hide().addClass('activeslide')
	    if (options.transition == 0) {
	        nextslide1.show(); $.inAnimation1 = false;
	    }
	    if (options.transition == 1) {
	        nextslide1.fadeIn(750, function () { $.inAnimation1 = false; });
	    }
	    if (options.transition == 2) {
	        nextslide1.show("slide", { direction: "up" }, 'slow', function () { $.inAnimation1 = false; });
	    }
	    if (options.transition == 3) {
	        nextslide1.show("slide", { direction: "right" }, 'slow', function () { $.inAnimation1 = false; });
	    }
	    if (options.transition == 4) {
	        nextslide1.show("slide", { direction: "down" }, 'slow', function () { $.inAnimation1 = false; });
	    }
	    if (options.transition == 5) {
	        nextslide1.show("slide", { direction: "left" }, 'slow', function () { $.inAnimation1 = false; });
	    }

	    $('#supersize1').resizenow1();
	}

	function nextslide2() {
	    if ($.inAnimation2) return false;
	    else $.inAnimation2 = true;
	    var options = $.extend($.fn.supersized2.defaults, $.fn.supersized2.options);
	    var currentslide2 = $('#supersize2 .activeslide');
	    currentslide2.removeClass('activeslide');

	    if (currentslide2.length == 0) currentslide2 = $('#supersize2 a:last');

	    var nextslide2 = currentslide2.next().length ? currentslide2.next() : $('#supersize2 a:first');
	    var prevslide2 = nextslide2.prev().length ? nextslide2.prev() : $('#supersize2 a:last');


	    //Display slide counter
	    if (options.slide_counter == 1) {
	        var slidecount2 = $('#slidecounter2 .slidenumber').html();
	        currentslide2.next().length ? slidecount2 ++ : slidecount2 = 1;
	        $('#slidecounter2 .slidenumber').html(slidecount2);
	    }

	    $('.prevslide2').removeClass('prevslide');
	    prevslide2.addClass('prevslide');

	    //Captions require img in <a>
	    if (options.slide_captions == 1) $('#slidecaption2').html($(nextslide2).find('img').attr('title'));

	    nextslide2.hide().addClass('activeslide')
	    if (options.transition == 0) {
	        nextslide2.show(); $.inAnimation2 = false;
	    }
	    if (options.transition == 1) {
	        nextslide2.fadeIn(750, function () { $.inAnimation2 = false; });
	    }
	    if (options.transition == 2) {
	        nextslide2.show("slide", { direction: "up" }, 'slow', function () { $.inAnimation2 = false; });
	    }
	    if (options.transition == 3) {
	        nextslide2.show("slide", { direction: "right" }, 'slow', function () { $.inAnimation2 = false; });
	    }
	    if (options.transition == 4) {
	        nextslide2.show("slide", { direction: "down" }, 'slow', function () { $.inAnimation2 = false; });
	    }
	    if (options.transition == 5) {
	        nextslide2.show("slide", { direction: "left" }, 'slow', function () { $.inAnimation2 = false; });
	    }

	    $('#supersize2').resizenow2();
	}

	function nextslide3() {
	    if ($.inAnimation3) return false;
	    else $.inAnimation3 = true;
	    var options = $.extend($.fn.supersized3.defaults, $.fn.supersized3.options);
	    var currentslide3 = $('#supersize3 .activeslide');
	    currentslide3.removeClass('activeslide');

	    if (currentslide3.length == 0) currentslide3 = $('#supersize3 a:last');

	    var nextslide3 = currentslide3.next().length ? currentslide3.next() : $('#supersize3 a:first');
	    var prevslide3 = nextslide3.prev().length ? nextslide3.prev() : $('#supersize3 a:last');


	    //Display slide counter
	    if (options.slide_counter == 1) {
	        var slidecount3 = $('#slidecounter3 .slidenumber').html();
	        currentslide3.next().length ? slidecount3 ++ : slidecount3 = 1;
	        $('#slidecounter3 .slidenumber').html(slidecount3);
	    }

	    $('.prevslide3').removeClass('prevslide');
	    prevslide3.addClass('prevslide');

	    //Captions require img in <a>
	    if (options.slide_captions == 1) $('#slidecaption3').html($(nextslide3).find('img').attr('title'));

	    nextslide3.hide().addClass('activeslide')
	    if (options.transition == 0) {
	        nextslide3.show(); $.inAnimation3 = false;
	    }
	    if (options.transition == 1) {
	        nextslide3.fadeIn(750, function () { $.inAnimation3 = false; });
	    }
	    if (options.transition == 2) {
	        nextslide3.show("slide", { direction: "up" }, 'slow', function () { $.inAnimation3 = false; });
	    }
	    if (options.transition == 3) {
	        nextslide3.show("slide", { direction: "right" }, 'slow', function () { $.inAnimation3 = false; });
	    }
	    if (options.transition == 4) {
	        nextslide3.show("slide", { direction: "down" }, 'slow', function () { $.inAnimation3 = false; });
	    }
	    if (options.transition == 5) {
	        nextslide3.show("slide", { direction: "left" }, 'slow', function () { $.inAnimation3 = false; });
	    }

	    $('#supersize3').resizenow3();
	}